#!/bin/sh

#usage: $ curl.shell $GITUB_TOKEN > yesterday.json
#see README.md for more information.

script='query {
  repository(owner:\"returntocorp\", name:\"semgrep\") {
    name
    issues(last:50) {
      nodes{
        title
        url
        assignees(first:3) {
          nodes { login }
        }
        closed
        createdAt
        updatedAt
        labels(first:5) {
          nodes {
            name
          }
        }
      }
    }
  }
  organization(login:\"returntocorp\") {
    project(number:50) {
      columns(first:10) {
       	nodes {
          name
       	  cards {
       	    nodes {
              content{
                __typename
                ...on Issue{
                  title
                  url
                  assignees(first:3) {
                     nodes {
                      login
                    }
                  }
                  closed
                  createdAt
                  updatedAt
                  labels(first:5) {
                    nodes{
                      name
                    }
                  }
                }
              }
              isArchived
              note
              creator {
                login
              }
       	    }
       	  }
       	}
      }
	  }
  }
}'
script="$(echo $script)"

token=$1
curl -H "Authorization: bearer $1" -X POST -d "{ \"query\": \"$script\" }" https://api.github.com/graphql | jq
